package org.yenn.pattern.aliyun.creational.abstractfactory;

import org.yenn.pattern.aliyun.service.Color;
import org.yenn.pattern.aliyun.service.Shape;
import org.yenn.pattern.aliyun.service.impl.Circle;
import org.yenn.pattern.aliyun.service.impl.Rectangle;
import org.yenn.pattern.aliyun.service.impl.Square;

/**
 * 步骤 6
 * 创建扩展了 AbstractFactory 的工厂类，基于给定的信息生成实体类的对象。
 */
public class ShapeFactory extends AbstractFactory{
    @Override
    Color getColor(String color) {
        return null;
    }

    @Override
    Shape getShape(String shapeType) {
        if(shapeType == null){
            return null;
        }
        if(shapeType.equalsIgnoreCase("CIRCLE")){
            return new Circle();
        } else if(shapeType.equalsIgnoreCase("RECTANGLE")){
            return new Rectangle();
        } else if(shapeType.equalsIgnoreCase("SQUARE")){
            return new Square();
        }
        return null;
    }
}
